<template>
  <div class="app-container">
    <!--工具栏-->
    <Search :crud="crud">
      <el-form-item label="姓名">
        <el-input v-model="query.empeName" placeholder="请输入"></el-input>
      </el-form-item>
      <el-form-item label="	身份证">
        <el-input v-model="query.empeIdCard" placeholder="请输入"></el-input>
      </el-form-item>
    </Search>
    <el-card>
      <el-table
        ref="table"
        border
        v-loading="crud.loading"
        :data="crud.data"
        style="width: 100%"
        @selection-change="crud.selectionChangeHandler"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
          fixed="left"
        />
        <el-table-column label="序号" type="index" width="50" align="center" />
        <el-table-column prop="empeName" label="姓名" align="center" />
        <el-table-column prop="empeCellPhone" label="手机号" align="center" />
        <el-table-column
          prop="empeGender"
          label="性别"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            {{ scope.row.empeGender === 0 ? '男' : '女' }}
          </template>
        </el-table-column>
        <el-table-column prop="empeIdCard" label="身份证" align="center" />
        <el-table-column prop="empeDegree" label="学历" align="center" />
        <el-table-column
          prop="empeDuty"
          label="应聘岗位"
          width="150"
          align="center"
        />
        <el-table-column label="操作" align="center" width="180" fixed="right">
          <template slot-scope="scope">
            <div>
              <el-button
                type="primary"
                size="mini"
                @click="handle(scope.row, 'edit')"
                >修改</el-button
              >
              <el-popconfirm
                title="是否确认推送？"
                @confirm="handlePush(scope.row)"
              >
                <el-button slot="reference" type="primary" size="mini"
                  >推送</el-button
                >
              </el-popconfirm>
            </div>
          </template>
        </el-table-column>
      </el-table>

      <!--分页组件-->
      <pagination />
    </el-card>
    <AddOrEditDialog
      ref="AddOrEditDialogRef"
      :successAfter="crud.refresh"
    ></AddOrEditDialog>
  </div>
</template>

<script>
import APIObj from '@/api/internalRecommend/index.js'
import CRUD, { presenter, header, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'
import udOperation from '@crud/UD.operation'
import Search from '@/components/Search'
import AddOrEditDialog from './components/AddOrEditDialog.vue'
import { showDictValue } from '@/utils'
export default {
  name: 'BrandIntroductionManage',
  components: {
    crudOperation,
    pagination,
    udOperation,
    Search,
    AddOrEditDialog,
  },
  cruds() {
    return CRUD({
      title: '内部推荐',
      url: 'internalInformation/queryPageList',
      requestMethod: 'post',
      sort: ['id,desc'],
    })
  },
  dicts: ['DEVICE_TYPE'],
  mixins: [presenter(), header(), crud()],
  data() {
    return {
      permission: {
        add: ['admin', 'job:add'],
        edit: ['admin', 'job:edit'],
        del: ['admin', 'job:del'],
      },
    }
  },
  methods: {
    showDictValue,
    // 改变状态
    changeEnabled(data, val) {
      product
        .tbDemoMoldTakingUpdateStatus({ id: data.id, isRelease: val })
        .then(() => {
          this.$notify({ message: '操作成功', type: 'success' })
          this.crud.refresh()
        })
        .catch((err) => {
          data.isRelease = !data.isRelease
          if (data.isRelease == '1') {
            data.isRelease = '0'
          } else {
            data.isRelease = '1'
          }
        })
    },
    // 删除与修改事件
    handle(row, type) {
      if (type == 'edit') {
        this.$refs.AddOrEditDialogRef.handleOpen(row)
      }
    },
    // 删除
    deleteHandle(params) {
      this.$confirm('确定删除吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {
        APIObj.deleteHandle(params)
          .then((res) => {
            this.$notify({ message: '操作成功', type: 'success' })
            this.crud.refresh()
          })
          .catch(() => {})
      })
    },
    // 新建成功
    submitSuccess() {
      this.crud.refresh()
    },
    async handlePush(row) {
      await APIObj.pushBackend(row.id)
      this.crud.refresh()
    },
  },
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
  text-align: left;
}
.item {
  margin-top: 10px;
  margin-right: 10px;
}
</style>
